using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace GAS.Common.Controls
{
	public partial class GASCaptionPane : Panel
	{
		private Label etqHeader;
		private Color onFocusBackColor;
		private Color onFocusForeColor;
		private Color onLeaveBackColor;
		private Color onLeaveForeColor;
		private Font headerFont;

		public GASCaptionPane()
		{
			InitializeComponent();

			InitComponent();
		}

		public GASCaptionPane(IContainer container)
		{
			container.Add(this);

			InitializeComponent();

			InitComponent();
		}

		private void InitComponent()
		{
			onFocusBackColor = Color.Gold;
			onFocusForeColor = Color.Black;
			onLeaveBackColor = Color.DodgerBlue;
			onLeaveForeColor = Color.White;

			etqHeader = new Label();
			this.Controls.Add(etqHeader);
			etqHeader.Dock = DockStyle.Top;
			etqHeader.AutoSize = false;
			etqHeader.TextAlign = ContentAlignment.MiddleLeft;
			etqHeader.SendToBack();

			etqHeader.Font = headerFont;

			etqHeader.BackColor = onLeaveBackColor;
			etqHeader.ForeColor = onLeaveForeColor;
		}

		public string HeaderText
		{
			get
			{
				return etqHeader.Text;
			}
			set
			{
				etqHeader.Text = value;
			}
		}

		public Color HeaderBackColor
		{
			get
			{
				return onLeaveBackColor;
			}
			set
			{
				onLeaveBackColor = value;
			}
		}

		public Color HeaderForeColor
		{
			get
			{
				return onLeaveForeColor;
			}
			set
			{
				onLeaveForeColor = value;
			}
		}

		public Color OnFocusForeColor
		{
			get
			{
				return onFocusForeColor;
			}
			set
			{
				onFocusForeColor = value;
			}
		}

		public Color OnFocusBackColor
		{
			get
			{
				return onFocusBackColor;
			}
			set
			{
				onFocusBackColor = value;
			}
		}

		public Font HeaderFont
		{
			get
			{
				return headerFont;
			}
			set
			{
				headerFont = value;
			}
		}


		protected override void OnEnter(EventArgs e)
		{
			base.OnEnter(e);

			etqHeader.ForeColor = onFocusForeColor;
			etqHeader.BackColor = onFocusBackColor;
		}

		protected override void OnLeave(EventArgs e)
		{
			base.OnLeave(e);

			etqHeader.ForeColor = onLeaveForeColor;
			etqHeader.BackColor = onLeaveBackColor;
		}

		private void ExidesCaptionPane_Paint(object sender, PaintEventArgs e)
		{
			etqHeader.SendToBack();
		}

		private void ExidesCaptionPane_SizeChanged(object sender, EventArgs e)
		{
			etqHeader.SendToBack();
		}
	}
}
